<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时</title>
    <style>
        div {
            width: 300px;
            height: 200px;
            margin: 0 auto;
            background-color: red;
            color: white;
            display: flex;
            flex-direction: row;
            text-align: center;
            justify-content: center;
            align-items: center;
        }
        span{
            background-color: black;
        }
    </style>
</head>
<body>
<div>
    <section>
        <p>请在以下时间前对视频进行点赞</p>
        <span class="daySpan"></span>
        <span class="hourSpan"></span>
        <span class="minuteSpan"></span>
        <span class="secondSpan"></span>
    </section>
</div>
<script>
    const daySpan = document.querySelector(".daySpan")
    const hourSpan = document.querySelector(".hourSpan")
    const minuteSpan = document.querySelector(".minuteSpan")
    const secondSpan = document.querySelector(".secondSpan")
    const deadline = new Date('2099-6-24 22:04')

    function countdown() {
        const now = new Date(), timeRemainning = deadline - now;
        let day, hour, minute, second;
        if (timeRemainning < 0) {
            return 0;
        }

        second = Math.floor(timeRemainning / 1000 % 60)
        minute = Math.floor(timeRemainning / 1000 / 60 % 60)
        hour = Math.floor(timeRemainning / 1000 / 60 / 60 % 24)
        day = Math.floor(timeRemainning / 1000 / 60 / 60 / 24)

        daySpan.innerHTML = day + "天"
        hourSpan.innerHTML = hour + "小时"
        minuteSpan.innerHTML = minute + "分"
        secondSpan.innerHTML = second + "秒"

        setTimeout(countdown, 1000);
    }

    countdown();
</script>
</body>
</html>